VERSION 5.00
Object = "{5E9E78A0-531B-11CF-91F6-C2863C385E30}#1.0#0"; "MSFLXGRD.OCX"
Begin VB.Form dlgNumerosClientes 
   BackColor       =   &H80000013&
   BorderStyle     =   3  'Fixed Dialog
   Caption         =   "Codigos Disponibles para clientes"
   ClientHeight    =   4260
   ClientLeft      =   2760
   ClientTop       =   3750
   ClientWidth     =   3945
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MinButton       =   0   'False
   ScaleHeight     =   4260
   ScaleWidth      =   3945
   ShowInTaskbar   =   0   'False
   Begin VB.CommandButton CancelButton 
      Caption         =   "Cancelar"
      Height          =   375
      Left            =   2640
      TabIndex        =   1
      Top             =   720
      Width           =   1215
   End
   Begin VB.CommandButton OKButton 
      Caption         =   "Aceptar"
      Height          =   375
      Left            =   2640
      TabIndex        =   0
      Top             =   240
      Width           =   1215
   End
   Begin MSFlexGridLib.MSFlexGrid lvConsulta 
      Height          =   3855
      Left            =   240
      TabIndex        =   2
      Top             =   120
      Width           =   2295
      _ExtentX        =   4048
      _ExtentY        =   6800
      _Version        =   393216
      Cols            =   1
      FixedCols       =   0
      Redraw          =   -1  'True
      SelectionMode   =   1
   End
End
Attribute VB_Name = "dlgNumerosClientes"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False

Option Explicit
Public idcliente As Integer
Dim stringitem As String
Dim rec As ADODB.Recordset



Private Sub Form_Load()
cn.BeginTrans
cn.Execute "select identity(int,1,1) numero into #temporal from cliente "
Set rec = cn.Execute("select numero from #temporal where numero not in (select id_cliente from cliente) order by 1")

If Not rec.RecordCount = 0 Then
lvConsulta.Cols = 1
lvConsulta.ColWidth(0) = 1000 'columna item
lvConsulta.TextMatrix(0, 0) = "Codigo"
lvConsulta.ColAlignment(0) = flexAlignRightCenter
lvConsulta.Rows = 1
rec.MoveFirst
While (Not rec.EOF)
    stringitem = Str(rec.Fields(0))
    lvConsulta.AddItem stringitem
    
    rec.MoveNext
    
Wend

End If
cn.RollbackTrans
End Sub

Private Sub lvConsulta_DblClick()
idcliente = lvConsulta.TextMatrix(lvConsulta.Row, 0)
Unload Me
End Sub

Private Sub OKButton_Click()
idcliente = lvConsulta.TextMatrix(lvConsulta.Row, 0)
Unload Me
End Sub

Private Sub CancelButton_Click()
idcliente = 0
Unload Me
End Sub

